package com.demo.principle.principleOfOpeningAndClosing;

public class Ocp2 {
    public static void main(String[] args) {
        Editor2 editor = new Editor2();
        editor.drewSharp(new Circle2());
        editor.drewSharp(new Rectangle2());
        editor.drewSharp(new Triangle2());
    }
}

abstract class Sharp2 {
    abstract void draw();
}

class Circle2 extends Sharp2 {
    @Override
    void draw() {
        System.out.println("圆形");
    }
}

class Rectangle2 extends Sharp2 {
    @Override
    void draw() {
        System.out.println("矩形");
    }
}

class Triangle2 extends Sharp2 {
    @Override
    void draw() {
        System.out.println("三角形");
    }
}

class Editor2 {
    public void drewSharp(Sharp2 sharp2) {
        sharp2.draw();
    }
}